package com.swz.dcrm.ui.viewmodel;

import androidx.lifecycle.MediatorLiveData;

import com.swz.dcrm.api.DcrmApi;
import com.swz.dcrm.model.BaseResponse;
import com.swz.dcrm.model.Work;
import com.xh.baselibrary.callback.BaseViewModel;
import com.xh.baselibrary.callback.CallBack;

import retrofit2.Retrofit;

public class HomeViewModel extends BaseViewModel {

    private Retrofit mRetrofit;
    private DcrmApi dcrmApi;
    private MediatorLiveData<BaseResponse<Work>>workCount;
    public HomeViewModel(Retrofit retrofit){
        this.mRetrofit=retrofit;
        dcrmApi=mRetrofit.create(DcrmApi.class);
    }

    public MediatorLiveData<BaseResponse<Work>>getWorkCount(){
        workCount=creatLiveData(workCount);
        dcrmApi.getWorkCount().enqueue(new CallBack<>(this,workCount));
        return workCount;
    }

}
